package com.endpoint.book.controller;

import com.endpoint.book.entity.Book;
import com.endpoint.book.service.IBookService;
import com.endpoint.common.utils.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 小说表 前端控制器
 * </p>
 *
 * @author cr
 * @since 2022-10-21
 */
@Api(tags = "书籍小说模块")
@RestController
@RequestMapping("/book/book")
public class BookController {

    @Autowired
    private IBookService bookService;


    @ApiOperation(value = "小说更新榜查询接口")
    @GetMapping("/updateRankList")
    public ResultBean<List<Book>> updateRankList(){
        List<Book> list = bookService.updateRankList();
        return ResultBean.ok(list);
    }


    @ApiOperation(value = "通过书籍id集合查询小说")
    @PostMapping("/listByIds")
    public ResultBean<List<Book>>listByIds(@RequestBody List<Long> ids){
        List<Book> books = bookService.listByIds(ids);
        return ResultBean.ok(books);
    }

    @GetMapping("/getBookList")
    public ResultBean<List<Book>> getBookList(){
        List<Book> list = bookService.list();
        return ResultBean.ok(list);
    }
}
